package ltd.newbee.mall.job;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import ltd.newbee.mall.api.mall.NewBeeMallPersonalAPI;
import ltd.newbee.mall.service.NewBeeMallUserService;
import ltd.newbee.mall.util.DateUtil;

/**
 * <pre>
 * 积分类定时任务
 * </pre>
 * @author rusth
 * @version $$ id: object.java ,v 0.1 2024/6/21 15:28 rusth Exp $$
 */
@Service
public class UserPointJob {
    private static final Logger LOGGER = LoggerFactory.getLogger(UserPointJob.class);

    @Autowired
    private NewBeeMallUserService userService;

    @Scheduled(cron = "0 1 0 * * ?")
    public void expirePoint() { // 每天0点01分过期
        String dateStr = DateUtil.getCurrentShortDate() + "000000";
        LOGGER.info("处理{},积分过期任务开始:{}", dateStr, DateUtil.getCurrentShortDateTimeMill());
        Date expireDate = DateUtil.dateParse(dateStr, DateUtil.SHORT_DATE_TIME_PATTERN);
        userService.userPointExpire(expireDate);
        LOGGER.info("处理{},积分过期任务结束:{}", dateStr, DateUtil.getCurrentShortDateTimeMill());
    }
}
